# coding:utf-8
# @Time      :2022/8/1611:45 PM
# @Author    :peiyu
# @FileName  :wellchosen_api
# @email     :geektime
# @Blog      :https://gitee.com/liupeiyu001/geektime_litemall.git
import json
from dataclasses import dataclass

from litemall.api.baseinfo import BaseInfo
from litemall.api.session_api import SessionApi
from litemall.framework.http import Request
from litemall.model import goods
from litemall.model.goods import Goods
from litemall.model.session import Session
from litemall.utils.readdata import Data



@dataclass
class WellChosenApi:


    def __init__(self):
        self.session = SessionApi()

    def search(self,goods:Goods):
        product =Request()
        product.method="get"
        product.type="json"
        product.query={"keyword":goods.name,"page":1,"limit":10,"categoryId":0}
        product.headers={"X-Litemall-Token": self.session.refresh_token()}
        product.path="/wx/goods/list"
        product.host=BaseInfo.host
        r=product.send()
        return r

